package com.pb.b2b.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pb.b2b.common.exception.CustomException;
import com.pb.b2b.common.service.impl.BaseServiceImpl;
import com.pb.b2b.dao.MarkDAO;
import com.pb.b2b.model.Mark;
import com.pb.b2b.model.enums.Status;
import com.pb.b2b.service.MarkService;

@Service
public class MarkServiceImpl extends BaseServiceImpl implements MarkService {

	@Autowired
	private MarkDAO markDAO;

	@Transactional
	public void createMark(Mark mark) {
		try {
			mark.setStatus(Status.AKTIVE);
			mark.setDateAdded(new Date());
			mark.setDateModified(new Date());
			save(mark);
		} catch (Exception e) {
			new CustomException(e, LanguageServiceImpl.class);
		}
	}

	@Transactional
	public List<Mark> getMarks() {
		List<Mark> list = null;
		try {
			list = markDAO.getMarks(Status.AKTIVE);
		} catch (Exception e) {
			new CustomException(e, LanguageServiceImpl.class);
		}
		return list;
	}

}
